package com.leessy.r229;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class ServiceBroadcastReceiver extends BroadcastReceiver {
    private static final String TAG = "ServiceBroadcastReceive";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent == null) return;
        Log.d(TAG, "onReceive: " + intent.getAction());
        String action = intent.getAction();
        if (action == Intent.ACTION_BOOT_COMPLETED) {
            Intent i = new Intent(Intent.ACTION_RUN);
            i.setClass(context, MService.class);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startService(i);
        }
        if (action == Intent.ACTION_PACKAGE_ADDED) {
            String schemeSpecificPart = intent.getData().getSchemeSpecificPart();
            Log.d(TAG, "onReceive: schemeSpecificPart=" + schemeSpecificPart);
        } else if (action == Intent.ACTION_PACKAGE_REMOVED) {
            String schemeSpecificPart = intent.getData().getSchemeSpecificPart();
            Log.d(TAG, "onReceive: schemeSpecificPart=" + schemeSpecificPart);
        } else if (action == Intent.ACTION_PACKAGE_REPLACED) {
            String schemeSpecificPart = intent.getData().getSchemeSpecificPart();
            Log.d(TAG, "onReceive: schemeSpecificPart=" + schemeSpecificPart);
        }
    }


}
